# -*- coding = utf-8 -*-
from flask import Flask,jsonify,render_template,request

from gaode import geocode,weatherinfo
LJY_key="65b04d34830504b4f0a6fe32550d797a"

app = Flask(__name__)

@app.route("/",methods = ["GET"])
def hello() ->str:
	return "welcome!"


@app.route("/first",methods = ["GET"])
def hello_first() ->"html":
	return render_template("Login.html")

@app.route("/search",methods = ["POST"])
def hello_login():
	name = request.form["name"]
	password = request.form["password"]
	a = password(name,password)
	maincity = request.form["city"]
	tianqi = weatherinfo(maincity)
	if a == "true":
		province1 = tianqi["lives"][0]['province']
		city1 = tianqi["lives"][0]['city']
		adcode1 = tianqi["lives"][0]['adcode']
		weather1 = tianqi["lives"][0]['weather']
		temperature1 = tianqi["lives"][0]['temperature']
		winddirection1 = tianqi["lives"][0]['winddirection']
		windpower1 = tianqi["lives"][0]['windpower']
		humidity1 = tianqi["lives"][0]['humidity']
		reporttime1 = tianqi["lives"][0]['reporttime']
		return render_template(
			"loginsuccess.html",
			the_geocode = tianqi,
			province = province1,
			city = city1,
			adcode = adcode1,
			weather = weather1,
			temperature = temperature1,
			winddirection = winddirection1,
			windpower = windpower1,
			humidity = humidity1,
			reporttime = reporttime1
			)
	else:
		return render_template("loginfail.html",loginfail = "登录失败")




if __name__ == '__main__':
	app.run(debug=True)